﻿#include "stdafx.h"
#include "MoveZeroes.h"

using namespace std;

namespace algorithm {
void CMoveZeroes::Move(vector<int>& nums)
{
    int nZeroIndex = -1;
    int size = (int)nums.size();
    for (int i = 0; i < size; i++) {
        if (nZeroIndex == -1) {
            if (nums[i] == 0) {
                nZeroIndex = i;
            }
            continue;
        }
        if (nums[i] != 0) {
            swap(nums[nZeroIndex], nums[i]);
            nZeroIndex++;
        }
    }
}
}
